﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CRMClient.Models.Compte;

namespace CRMClient.Views.AccountViews
{
    public partial class UpdateAccount : PhoneApplicationPage
    {
        public UpdateAccount()
        {
            InitializeComponent();
            DataContext = App.AccountViewModel;
        }

        private void appBarOkButton_Click(object sender, EventArgs e)
        {
            if(name.Text.Equals("")){
                MessageBox.Show("Account name empty");
            }
            else
            App.AccountViewModel.upd(name.Text,tel.Text,email.Text,city.Text);
            App.AccountViewModel.Account = new Response { name = name.Text, address1_telephone1 = tel.Text, emailaddress1 = email.Text, address1_city = city.Text };
            if (NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
            }
        }

        private void appBarCancelButton_Click(object sender, EventArgs e)
        {
            if (NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
            }
        }
    }
}